
package com.hlkj.pay.vo.order.resp;

import com.hlkj.pay.vo.BaseMerchantResp;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

/**
 * 订单统计
 * 
 * @TableName t_statistics
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class OrderStatisticsResp extends BaseMerchantResp {

    /**
     * 订单笔数
     */
    @Schema(description = "订单笔数")
    private Integer submitOrderCount;

    /**
     * 支付订单笔数
     */
    @Schema(description = "支付订单笔数")
    private Integer payOrderCount;

    /**
     * 订单金额
     */
    @Schema(description = "订单金额")
    private BigDecimal submitOrderAmount;

    /**
     * 支付订单金额
     */
    @Schema(description = "支付订单金额")
    private BigDecimal payOrderAmount;

    /**
     * 退款笔数
     */
    @Schema(description = "退款笔数")
    private Integer refundCount;

    /**
     * 退款金额
     */
    @Schema(description = "退款金额")
    private BigDecimal refundAmount;

    /**
     * 平台交易手续费
     */
    @Schema(description = "平台交易手续费")
    private BigDecimal feeAmount;

    /**
     * 机构交易手续费
     */
    @Schema(description = "机构交易手续费")
    private BigDecimal channelFeeAmount;

    /**
     * 充值金额
     */
    @Schema(description = "充值金额")
    private BigDecimal chargeAmount;

    /**
     * 投诉订单数
     */
    @Schema(description = "投诉订单数")
    private Integer complainCount;
    /**
     * 投诉订单数
     */
    @Schema(description = "支付方式查询返回参数 1 微信 2 支付宝 3 云闪付 4 数字人民币 5 快捷 6 网银 7 功能 8 其他 支付方式")
    private String payType;
    /**
     * 商户商户号
     */
    @Schema(description = "appId查询返回参数 appId")
    private String appId;
    /**
     * 商户商户号
     */
    @Schema(description = "机构查询返回参数 机构编码")
    private String agentId;
    /**
     * 商户商户号
     */
    @Schema(description = "机构查询返回参数 机构名称")
    private String agentName;
    
    /**
     * 商户商户号
     */
    @Schema(description = "支付通道查询返回参数 支付通道编码")
    private String mchChannelCode;

    /**
     * 商户商户号
     */
    @Schema(description = "支付渠道查询返回参数 支付渠道编码")
    private String channelCode;
    @Schema(description = "支付渠道描述")
    private String channelCodeDesc;
    @Schema(description = "autcode")
    private String autCode;
    /**
     * 商户商户号
     */
    @Schema(description = "支付通道查询返回参数 子商户号")
    private String subMchId;
    /**
     * 统计时间
     */
    @Schema(description = "统计时间")
    private Long time;
    /**
     * 统计时间
     */
    @Schema(description = "统计时间描述")
    private String timeDesc;
    /**
     * 商户号
     */
    @Schema(description = "后端字段 前端忽略")
    private String relationId;
    @Schema(description = "统计方式对应的值 如天 周 月 年的值")
    private String statisticsTypeValue;

    /**
     * 微信投诉率
     */
    @Schema(description = "微信投诉率")
    private Double wxComplainRate;

    public Double getWxComplainRate() {
        if (this.wxOrderCount > 0 && this.complainCount > 0) {
            double result = (double)this.complainCount / this.wxOrderCount * 100;
            return Math.round(result * 100) / 100.0;
        }
        return wxComplainRate;
    }

    /**
     * 微信投诉率
     */
    @Schema(description = "微信订单数")
    private Integer wxOrderCount;

    /**
     * 退款笔数
     */
    @Schema(description = "代付笔数")
    private Integer paymentCount;

    /**
     * 退款金额
     */
    @Schema(description = "代付金额")
    private BigDecimal paymentAmount;
}
